﻿// Decompiled with JetBrains decompiler
// Type: TaleWorlds.CampaignSystem.LogEntries.CharacterMarriedLogEntry
// Assembly: TaleWorlds.CampaignSystem, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: E85F8C15-4DF6-4E9C-A58A-29177E40D07A
// Assembly location: D:\steam\steamapps\common\Mount & Blade II Bannerlord\bin\Win64_Shipping_Client\TaleWorlds.CampaignSystem.dll

using Helpers;
using System.Collections.Generic;
using TaleWorlds.Core;
using TaleWorlds.Localization;
using TaleWorlds.ObjectSystem;
using TaleWorlds.SaveSystem;

#nullable disable
namespace TaleWorlds.CampaignSystem.LogEntries
{
  public class CharacterMarriedLogEntry : LogEntry, IEncyclopediaLog, IChatNotification
  {
    [SaveableField(130)]
    public readonly Hero MarriedHero;
    [SaveableField(131)]
    public readonly Hero MarriedTo;

    internal static void AutoGeneratedStaticCollectObjectsCharacterMarriedLogEntry(
      object o,
      List<object> collectedObjects)
    {
      ((LogEntry) o).AutoGeneratedInstanceCollectObjects(collectedObjects);
    }

    protected override void AutoGeneratedInstanceCollectObjects(List<object> collectedObjects)
    {
      base.AutoGeneratedInstanceCollectObjects(collectedObjects);
      collectedObjects.Add((object) this.MarriedHero);
      collectedObjects.Add((object) this.MarriedTo);
    }

    internal static object AutoGeneratedGetMemberValueMarriedHero(object o)
    {
      return (object) ((CharacterMarriedLogEntry) o).MarriedHero;
    }

    internal static object AutoGeneratedGetMemberValueMarriedTo(object o)
    {
      return (object) ((CharacterMarriedLogEntry) o).MarriedTo;
    }

    public override CampaignTime KeepInHistoryTime => CampaignTime.Weeks(240f);

    public override ChatNotificationType NotificationType
    {
      get
      {
        return this.DiplomaticNotification((IFaction) this.MarriedHero.Clan, (IFaction) this.MarriedTo.Clan);
      }
    }

    public bool IsVisibleNotification
    {
      get => this.MarriedHero.CharacterObject.IsHero && this.MarriedTo.CharacterObject.IsHero;
    }

    public CharacterMarriedLogEntry(Hero marriedHero, Hero marriedTo)
    {
      this.MarriedHero = marriedHero;
      this.MarriedTo = marriedTo;
    }

    public override string ToString() => this.GetEncyclopediaText().ToString();

    public TextObject GetNotificationText()
    {
      TextObject text = GameTexts.FindText("str_hero_married_hero");
      StringHelpers.SetCharacterProperties("MARRIED_TO", this.MarriedTo.CharacterObject, text);
      StringHelpers.SetCharacterProperties("MARRIED_HERO", this.MarriedHero.CharacterObject, text);
      return text;
    }

    public bool IsVisibleInEncyclopediaPageOf<T>(T obj) where T : MBObjectBase
    {
      return (object) obj == this.MarriedHero || (object) obj == this.MarriedTo;
    }

    public TextObject GetEncyclopediaText() => this.GetNotificationText();
  }
}
